package com.qmhl.toolposition

import android.app.Application
import android.util.Log
import com.amap.api.location.AMapLocationClient
import com.hjq.toast.Toaster
import com.qmhl.toolposition.utils.PreferenceUtil
import com.qmhl.toolposition.utils.SPUtils
import com.tencent.bugly.crashreport.CrashReport
import com.tencent.mmkv.MMKV
import com.umeng.commonsdk.UMConfigure
import com.umeng.sms.UMSMS
import com.umeng.socialize.PlatformConfig
import com.umeng.umverify.UMVerifyHelper
import com.umeng.umverify.listener.UMTokenResultListener

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        val rootDir: String = MMKV.initialize(this)
        instant = this

        SPUtils.init(this)


        AMapLocationClient.updatePrivacyShow(this, true, true);
        AMapLocationClient.updatePrivacyAgree(this, true);

        //bug上报
        CrashReport.initCrashReport(applicationContext, "e486f8ebc8", false);

        // 初始化 Toast 框架
        Toaster.init(this);

        initUmeng()


    }

    private fun initUmeng() {
        /**
         *  为满足工信部合规要求，请确保按照合规指南进行预初始化
         *  https://developer.umeng.com/docs/119267/detail/182050
         */
        UMConfigure.preInit(this, "654ae98fb2f6fa00ba79abba", "toutiao")
        UMConfigure.init(
            this,
            "654ae98fb2f6fa00ba79abba",
            "toutiao",
            UMConfigure.DEVICE_TYPE_PHONE,
            ""
        )

        UMSMS.setSMSSDKInfo(this,"lcU6+u5mO++YwRG2qf3uSqVLe/c1ceBIQWwOIUVeJlQgfgBhskqbBoGanp2zdZA2UfqKND4ks1TK85MpTAOvkM1qaNRpBtQOmmPa4XQnSUViQ/jvpyBax9zguEKZVR8aDE0Bmg+vxfoVPpmJOonMhQLq28j9laCQTvCowMI0FErxrvLogX0LnJzOMNDmzoCX8T4P/gzjpJ6cF3JVlM7tn3GDNUNtMlj8aFw3KBItAVE2nwVwsXVMzboR0x/95CyeM0+eP1mvSIjO7+vPQ8k7sGkmtgH5pDyVoJrslEEvIN8/jIflBaR1KhvJ4j33cVyb");

        //友盟微信分享
        // 微信设置
        PlatformConfig.setWeixin("wx6bb40171e11f15da","7110e012e2bc4997726123ff076559ab");
        PlatformConfig.setWXFileProvider("com.qmhl.toolposition.fileprovider");


        val authHelper = UMVerifyHelper.getInstance(this, object : UMTokenResultListener {
            override fun onTokenSuccess(ret: String) {
                Log.e("init", "onTokenSuccess: $ret")
            }

            override fun onTokenFailed(ret: String) {
                Log.e("init", "onTokenFailed: $ret")
            }
        })
        authHelper.setLoggerEnable(true)
        authHelper.setAuthSDKInfo("lcU6+u5mO++YwRG2qf3uSqVLe/c1ceBIQWwOIUVeJlQgfgBhskqbBoGanp2zdZA2UfqKND4ks1TK85MpTAOvkM1qaNRpBtQOmmPa4XQnSUViQ/jvpyBax9zguEKZVR8aDE0Bmg+vxfoVPpmJOonMhQLq28j9laCQTvCowMI0FErxrvLogX0LnJzOMNDmzoCX8T4P/gzjpJ6cF3JVlM7tn3GDNUNtMlj8aFw3KBItAVE2nwVwsXVMzboR0x/95CyeM0+eP1mvSIjO7+vPQ8k7sGkmtgH5pDyVoJrslEEvIN8/jIflBaR1KhvJ4j33cVyb\t")
    }


    companion object {

        lateinit var instant: MyApplication
    }
}